// 这个组件并不是为了做视图,而是功能性的组件
import React from "react"
import { Navigate } from "react-router-dom"
import useAuth from "@/hooks/useAuth"
// ts
interface ProtectedRouteProps {
  element: React.ReactNode;
  // 可以添加其他需要的属性，如权限检查等
}
const ProtectedRoute:React.FC<ProtectedRouteProps> = ({element})=>{
  const isAuthenticated = useAuth()

  return isAuthenticated ? <>{ element }</> : <Navigate to="/login" />
}


export default ProtectedRoute